package com.lc.proxy;


import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * dao 的工厂类
 */
public class DaoProxyFactory {

    public <T> T getDaoProxy(ClassLoader classLoader, Class[] classes, InvocationHandler invocationHandler) {
        return (T) Proxy.newProxyInstance(classLoader, classes, invocationHandler);
    }

    public <T> T getMapper(Class<?> type) {
        return getDaoProxy(type.getClassLoader(), new Class[]{type}, new DaoProxy());
    }

}
